$(function () {

    var itemIndex = 0;

    var tabLoadEndArray = [false, false, false,false];
    var tabScroolTopArray = [0, 0, 0, 0];
    var page0 = 1;
    var page1 = 1;
    var page2 = 1;
    var page3 = 1;
    // dropload
    var dropload = $('.khfxWarp').dropload({
        scrollArea: window,
        domDown: {
            domClass: 'dropload-down',
            domRefresh: '<div class="dropload-refresh">上拉加载更多</div>',
            domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
            domNoData: '<div class="dropload-noData">没有更多数据了</div>'
        },
        loadDownFn: function (me) {
            setTimeout(function () {
                if (tabLoadEndArray[itemIndex]) {
                    me.resetload();
                    me.lock();
                    me.noData();
                    me.resetload();
                    return;
                }
                if (itemIndex == 0) {
                	$.get("/load/loadUserDiaryList", {page: page0},function(result){
                		if(result.code == 0){
                			page0 ++;
                			$('#userdatalist0').append(result.data);
                			if(!result.hasnext){
                				tabLoadEndArray[itemIndex] = true;
                			}
                		}
                	});
                }else if (itemIndex == 1) {
                	$.get("/load/loadLikeDiaryList", {page: page1},function(result){
                		if(result.code == 0){
                			page1 ++;
                			$('#userdatalist1').append(result.data);
                			if(!result.hasnext){
                				tabLoadEndArray[itemIndex] = true;
                			}
                		}
                	});
                }else if (itemIndex == 2) {
                	$.get("/load/loadFollowList", {page: page2},function(result){
                		if(result.code == 0){
                			page2 ++;
                			$('#userdatalist2').append(result.data);
                			if(!result.hasnext){
                				tabLoadEndArray[itemIndex] = true;
                			}
                		}
                	});
                }else if (itemIndex == 3) {
                	$.get("/load/loadFansList", {page: page3},function(result){
                		if(result.code == 0){
                			page3 ++;
                			$('#userdatalist3').append(result.data);
                			if(!result.hasnext){
                				tabLoadEndArray[itemIndex] = true;
                			}
                		}
                	});
                }
                me.resetload();
            }, 500);
        }
    });


    $('.personal-classLabel-li span').on('click', function () {
        tabScroolTopArray[itemIndex] = $(window).scrollTop();
        var $this = $(this);
        itemIndex = $this.data('index');
        $(window).scrollTop(tabScroolTopArray[itemIndex]);
        $('.personal-classLabel-li span').removeClass('personal-classLabel-liActive');
        $(this).addClass('personal-classLabel-liActive');
        $('.uuuu').eq(itemIndex).show().siblings('.uuuu').hide();
        if (!tabLoadEndArray[itemIndex]) {
            dropload.unlock();
            dropload.noData(false);
        } else {
            dropload.lock('down');
            dropload.noData();
        }
        dropload.resetload();
    });
});